/**
 * Copyright 2010 Per-Erik Bergman (per-erik.bergman@jayway.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package se.jayway.opengl.tutorial.mesh;


/**
 * SimplePlane is a setup class for Mesh that creates a plane mesh.
 * 
 * @author Per-Erik Bergman (per-erik.bergman@jayway.com)
 * 
 */
public class TwoDPlane extends Mesh2D {
	float[] faBack = new float[16];	
	void initImage(float fa[], float x, float y, float w, float h, 
			float tx, float ty, float tsize){
		fa[0] = x; fa[1]= y;
		fa[2]=x+w; fa[3]=y;
		fa[4]=x; fa[5]=y+h;
		fa[6]=x+w; fa[7]=y+h;
		fa[8]= tx/tsize;
		fa[9]= ty/tsize;
		fa[10]= (tx+w)/tsize;
		fa[11] = ty/tsize;
		fa[12] = tx/tsize;
		fa[13] = (ty+h)/tsize;
		fa[14] = (tx+w)/tsize;
		fa[15] = (ty+h)/tsize;
	}

	/**
	 * Create a plane with a default with and height of 1 unit.
	 */
	public TwoDPlane() {
		initImage(faBack, 0, 0, 320, 480, 0, 0, 512);
		
//		short[] shortIndices = { 0, 1, 2, 1, 3, 2 };
//		hasColor = false;
//		hasTexCoords = true;
//
//		vertexSize = (3 + (hasColor ? 4 : 0) + (hasTexCoords ? 2 : 0)) * 4;
//		int maxVertices = floatVertices.length * 4 / vertexSize;
//		tmpBuffer = new int[floatVertices.length];
//		int maxIndices = shortIndices.length;
//		ByteBuffer buffer = ByteBuffer.allocateDirect(maxVertices * vertexSize);
//		buffer.order(ByteOrder.nativeOrder());
//		vertices = buffer.asIntBuffer();
//
//		if (maxIndices > 0) {
//			buffer = ByteBuffer.allocateDirect(maxIndices * Short.SIZE / 8);
//			buffer.order(ByteOrder.nativeOrder());
//			indices = buffer.asShortBuffer();
//		} else {
//			indices = null;
//		}
//
//		setVertices(floatVertices);
//		setIndices(shortIndices);
//		// setTextureCoordinates(textureCoordinates);
	}

	/**
	 * Create a plane.
	 * 
	 * @param width
	 *            the width of the plane.
	 * @param height
	 *            the height of the plane.
	 */
	public TwoDPlane(float width, float height) {

	}
}
